@ECHO OFF

ECHO ---- This batch file should be ran under yoda root directory ----

cd /d %~dp0yoda

:SETENV
ECHO SETENV
set JAVA_HOME=D:\tools\jdk1.5.0_11
set PATH=%JAVA_HOME%\bin;%PATH%

set WS_PATH=%CD%
set VTBA_HOME=%WS_PATH%export\home

call .\build\setup_env.bat

rem override previous ANT_OPTS setting, just don't want to modify setup_env.bat.
set ANT_OPTS=-Xms512m -Xmx1024m -XX:MaxPermSize=390m

:PREREQ
@ECHO ON
set AUTOBUILDLOG=autobuildlog
IF EXIST autobuildlog_bak rd /s/q autobuildlog_bak
IF EXIST autobuildlog rename autobuildlog autobuildlog_bak
IF NOT EXIST autobuildlog mkdir %AUTOBUILDLOG%
set ALPRE=autobuild_

if "%1." == "nopull." GOTO BUILD
:SVNPULL
ECHO SVNPULL
ECHO     Update directory ".\build" from SVN server.
cd build
call svn cleanup >../%AUTOBUILDLOG%/%ALPRE%build_cleanup.log
call svn up >../%AUTOBUILDLOG%/%ALPRE%build_svnup.log
cd ..

ECHO     Update directory ".\shared" from SVN server.
cd shared
call svn cleanup >../%AUTOBUILDLOG%/%ALPRE%shared_cleanup.log
call svn up >../%AUTOBUILDLOG%/%ALPRE%shared_svnup.log
cd ..

ECHO     Update directory ".\bw" from SVN server.
cd bw
call svn cleanup >../%AUTOBUILDLOG%/%ALPRE%bw_dev_cleanup.log
call svn up >../%AUTOBUILDLOG%/%ALPRE%bw_dev_svnup.log
cd ..

ECHO     Update directory ".\connectors" from SVN server.
cd connectors
call svn cleanup >../%AUTOBUILDLOG%/%ALPRE%Connectors_cleanup.log
call svn up >../%AUTOBUILDLOG%/%ALPRE%Connectors_svnup.log
cd ..

ECHO     Update directory ".\m3o" from SVN server.
cd m3o
call svn cleanup >../%AUTOBUILDLOG%/%ALPRE%m3o_cleanup.log
call svn up >../%AUTOBUILDLOG%/%ALPRE%m3o_svnup.log
cd ..

ECHO     Update directory ".\transformers\axt" from SVN server.
cd transformers/axt
call svn cleanup >../../%AUTOBUILDLOG%/%ALPRE%axt_cleanup.log
call svn up >../../%AUTOBUILDLOG%/%ALPRE%axt_svnup.log
cd ../..

ECHO     Update directory ".\opbook" from SVN server.
cd opbook
call svn cleanup >../%AUTOBUILDLOG%/%ALPRE%opbook_cleanup.log
call svn up >../%AUTOBUILDLOG%/%ALPRE%opbook_svnup.log
cd ..

ECHO     Update directory ".\suites" from SVN server.
cd suites
call svn cleanup >../%AUTOBUILDLOG%/%ALPRE%suites_cleanup.log
call svn up >../%AUTOBUILDLOG%/%ALPRE%suites_svnup.log
cd ..

ECHO     Update directory ".\esms" from SVN server.
cd esms
call svn cleanup >../%AUTOBUILDLOG%/%ALPRE%esms_cleanup.log
call svn up >../%AUTOBUILDLOG%/%ALPRE%esms_svnup.log
cd ..

svn up build.xml

:BUILD
IF "%1." == "nobuild." GOTO END

IF EXIST export_bak rd /s/q export_bak
::IF EXIST export rename export export_bak
IF EXIST export rd /s/q export

ECHO BUILD
ECHO     Build ".\shared" directory...
cd shared
call ant installer -l ../%AUTOBUILDLOG%/%ALPRE%shared.log
cd ..

ECHO     Build ".\bw"(installer) directory...
cd bw
call ant -l ../%AUTOBUILDLOG%/%ALPRE%bw.log
call ant installer -l ../%AUTOBUILDLOG%/%ALPRE%bw_install.log
cd ..

ECHO     Build ".\m3o"(installer) directory...
cd m3o
call ant -l ../%AUTOBUILDLOG%/%ALPRE%m3o.log
call ant installer -l ../%AUTOBUILDLOG%/%ALPRE%m3o_install.log
::ant artifacts -l ../%AUTOBUILDLOG%/%ALPRE%fetch.log
cd ..

ECHO     Build ".\connectors"(installer) directory...
cd connectors
call ant -l ../%AUTOBUILDLOG%/%ALPRE%Connectors.log
call ant installer -l ../%AUTOBUILDLOG%/%ALPRE%Connectors_install.log
cd ..

ECHO     Build ".\transformers\axt"(installer) directory...
cd transformers/axt
call ant -l ../../%AUTOBUILDLOG%/%ALPRE%axt.log
call ant installer -l ../../%AUTOBUILDLOG%/%ALPRE%axt_install.log
cd ../..

ECHO     Build ".\opbook" directory...
cd opbook
call ant -l ../%AUTOBUILDLOG%/%ALPRE%opbook.log
call ant installer -l ../%AUTOBUILDLOG%/%ALPRE%opbook_install.log
cd ..

ECHO     Build ".\esms" directory...
cd esms
call ant -l ../%AUTOBUILDLOG%/%ALPRE%esms.log
call ant installer -l ../%AUTOBUILDLOG%/%ALPRE%esms_install.log
cd ..

ECHO     Build ".\suites" directory...
cd suites
call ant -l ../%AUTOBUILDLOG%/%ALPRE%SuiteInstallers.log
cd ..

:END